package com.link2room.rodimus.service.impl;

import com.link2room.common.redis.RedisUtil;
import com.link2room.rodimus.constant.SchedulesConstant;
import com.link2room.rodimus.service.ISchedulesService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/3/23.
 */
@Component("schedulesService")
public class SchedulesServiceImpl implements ISchedulesService {
    @Resource
    private RedisUtil redisUtil;
    @Override
    public String getIncomedetailScheduleOptid(String lhotelGroupCode) {
        String optidKey = getOptidKey(lhotelGroupCode);
        if(redisUtil.exists(optidKey)){
            return (String) redisUtil.get(optidKey);
        }else{
            return null;
        }
    }

    @Override
    public void setIncomedetailScheduleOptid(String lhotelGroupCode, String optid) {
        String optidKey = getOptidKey(lhotelGroupCode);
        redisUtil.set(optidKey,optid,7*24*60*60L);
    }

    private String getOptidKey (String lhotelGroupCode){
        return SchedulesConstant.PREFIX.INCOMEDETAIL+lhotelGroupCode;
    }
}
